import { Injectable } from '@angular/core';
import { Params } from '@angular/router';
import { DriveEnginService } from './drive-engin.service';

@Injectable({
  providedIn: 'root'
})
export class ActionHandlerService {

  constructor(private deSvc:DriveEnginService) { 
  }
 
  public async handleAction(action: string, params: Params) { 

    switch (action) {
      case 'de_execute':
        this.de_execute(params);
        break; 
      default:
        console.warn(`Unhandled action: ${action}`);
    } 
  }

  private de_execute(params: Params): void { 
    try {
      const path = params['path'] ? decodeURIComponent(params['path']) : '/';
      const driver_id = Number(params['driver_id']);
      const operation_id = Number(params['operation_id']);
      const type = params['type']; 
      this.deSvc.execute(driver_id,operation_id,path,type);
    } catch (error) {
      console.error('Error executing action:', error);
    }
    finally {
        
  }
}



}
